/*
 * @Author: Jiraiya
 * @Date: 2020-06-12 11:04:41
 * @LastEditors: Jiraiya
 * @LastEditTime: 2020-06-12 11:15:22
 * @Description: 
 */ 
const ws = new WebSocket('ws://localhost:8001');
ws.onopen = function(){
    console.log('打开')
    setInterval(() => {
        ws.send(new Date().toISOString())
    }, 2000);
}
ws.onerror = function (){
    console.log('错误')
}
ws.onmessage = function(event){
    console.log(event.data)
}
ws.onclose = function(){
    console.log('关闭')
}